<template>
		<view id="signupgroup">
			<view class="wrapper">
					<view class="signup_content">
							<scroll-view scroll-y="true" >
								<view class="group_cell" v-for="(item,index) in groupList" :key='index'>
									<view class="cell_header">
										<view>
											{{item.groupname?item.groupname:''}}
										</view>
										<view>
											<text class="blue" v-show='typeID==1'>
												待授权
											</text>
											<text class="red" v-show='typeID==2'>
												授权未通过
											</text>
											<text class="green" v-show='typeID==3'>
												已授权
											</text>
										</view>
									</view>
									<view class="cell-content">
										<view class="cells">
											<text>报名时间:</text>{{item.r_begintime.slice(0,16)+"至"+item.r_endtime.slice(0,16)}}
										</view>
										<view class="cells">
											<text>比赛时间:</text>	{{item.begintime.slice(0,16)+"至"+item.endtime.slice(0,16)}}
										</view>
										<view class="cell">
											<view class="">
											<text>等级限制:</text>{{item.gradeText?item.gradeText:""}}
											</view>
											<view class="cell_count">
												{{item.costSum}}
											</view>
										</view>
									</view>
								</view>
							</scroll-view>
					</view>
					
				</view>
			</view>
			
		</view>
</template>

<script>
	import {authorizedDetail} from "@/common/api.js";
	export default{
		data(){
			return{
				isCheckStep:false, //是否显示审核进度
				id:'',
				groupList:[],
				detail_type:"",
				statusList:[{type:"1",checkStatus:'isAuthorizeding'},{type:"2",checkStatus:'isNoAuthorized'},{type:"3",checkStatus:'isAuthorized'}],  //状态
				typeID:"",
				org_id:""
			}
		},
		onLoad(e){
			var _this=this;
			_this.id=e.id;
			_this.org_id=e.org_id;
			// console.log(_this.id,_this.org_id)
			_this.detail_type=_this.statusList.filter(function(item,index){
				return item.type==e.type
			})[0].checkStatus;
			_this.typeID=_this.statusList.filter(function(item,index){
				return item.type==e.type
			})[0].type;
			switch(_this.typeID){
				case '1': return _this.detail_type='未授权';
				case "2": return _this.detail_type="授权未通过";
				case "3": return _this.detail_type="已授权"
			}

			// _this.getGroupData()
		},
		onShow() {
			var _this=this;
			_this.getGroupData();
		},
		methods:{
			back(){
				var _this=this;
				uni.navigateTo({
					url:'/pages/competitionAudit/authorized/authorizedDetail?id='+_this.id+"&type="+_this.typeID
				})
			},
			getGroupData(){
				// console.log(this.id)
				var _this=this,data={
					id:_this.id,
					org_id:_this.org_id
				};
				authorizedDetail(data).then(function(res){
					var e=res.data;
					if(e.errcode==0){
						var list=""
						if(e.data.eventconfig.jsondatagroup){
							list=JSON.parse(e.data.eventconfig.jsondatagroup);
							_this.groupList=list['step1'];
							_this.groupList=_this.feeGet(_this.groupList,list['step2'])
						}
					}else if(e.errcode==1000||e.errcode==1001){
							uni.removeStorageSync('token');
							uni.reLaunch({
								url:'/pages/home/welcome'
							})
						}else{
						uni.showToast({
							position: 'center',
							icon: 'none',
							title: e.msg
						});
					}
				})
			},
			//赛事报名费
			feeGet(step,newStep){
			  const that = this;
			  // var num=''
			  if(step && step.length>0){
			    step.map(function(item,index){
			  		if(item.cost&&item.cost.length>0){
			  			item.cost.map(function(items,indexs){
			  				if(items.costName=="报名费"){
			  					item.costSum="￥"+items['cost'];
			  				}else{
									if(newStep){
										item.costSum="￥"+newStep[0]['cost']
									}
			  				}
			  			})
			  		}else{
							if(newStep){
								item.costSum="￥"+newStep[0]['cost']
							}
			  		}
			  	})
			  }
			  return step;
			},
		}
	}
</script>

<style lang="less" scoped>
	html,body{
		background: #F6F7F9;
	}
	#signupgroup{
		background: #F6F7F9;
		font-size: 14px;
		height: 100vh;
		.blue{
			color: #2D8DFF;
		}
		.red{
			color: #FF535A;
		}
		.green{
			color: #81D25A;
		}
	}
	.wrapper{
		display: flex;
		flex-flow: column;
	}
	.signup_header{
		position: relative;
		padding: 5px 0;
		height: 24px;
		font-size: 18px;
		text-align: center;
		background: #fff;
		border-bottom: 1px solid #F1F1F2;
		.back{
			position: absolute;
			left: 0;
			top: 0;
		}
	}
	.signup_content{
		margin: 0 16px ;
		flex: 1;
		// height: 100px;
		// background: red;
		.group_cell{
			min-height: 127px;
			padding: 11px 12px 13px;
			background: #fff;
			margin-top: 14px;
			border-radius: 8px;
			.cell_header{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				border-bottom: 1px solid #F1F1F2;
				view:first-child{
					font-size:16px;
					width: 75%;
				}
				view:last-child{
					width: 25%;
					align-self: center;
					text-align: right;
				}
			}
			.cell-content{
				margin-top: 4px;
				color: #8E8E93;
				.cells{
					margin-top: 9px;
					text{
						padding-right: 5px;
					}
				}
				.cell{
					margin-top: 9px;
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					text{
						padding-right: 5px;
					}
				}
				.cell_count{
					font-size: 16px;
					color: #FF6B6B;
				}
			}
		}
	}
</style>
